<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>button-focus-swing-animation</title>
    <style>
        .swing-button {
            display: inline-block;
            padding: 6px 26px;
            outline: none;
            transition: all .4s ease-in-out;
            background-color: #2396ef;
            color: #fff;
            cursor: pointer;
            border-radius: 4px;
            border: 1px solid #1e89ee;
        }

        .swing-button:focus {
            animation: swing 1s ease;
            /* animation-iteration-count: 1; */
        }

        @keyframes swing {
            15% {
                transform: translateX(5px);
            }

            30% {
                transform: translateX(-5px);
            }

            50% {
                transform: translateX(3px);
            }

            65% {
                transform: translateX(-3px);
            }

            80% {
                transform: translateX(2px);
            }

            100% {
                transform: translateX(0);
            }
        }
    </style>
</head>

<body>
    <button class="swing-button">Submit</button>
</body>

</html>